package cn.kwq.project_manger.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.stp.StpUtil;
import cn.kwq.project_manger.common.R;
import cn.kwq.project_manger.common.RES;
import cn.kwq.project_manger.pojo.dto.AddResumeDto;
import cn.kwq.project_manger.service.ResumeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Slf4j
@Api(tags ="简历")
@RestController
@RequestMapping("/resume/")
@SaCheckLogin
public class ResumeController {
    @Autowired
    ResumeService resumeService;

    /**
     * @return
     */
    @ApiOperation("获取简历（没保存过简历的只有教务系统信息返回）")
    @GetMapping("getResume")
    public RES getResume() {
        return R.ok(resumeService.getResume(StpUtil.getLoginIdAsLong()));
    }
    /**
     * @return
     */
    @ApiOperation("编辑简历（新建和编辑保存同一个api，即同一个按钮）")
    @PostMapping ("saveResume")
    public RES saveResume(@RequestBody AddResumeDto addResumeDto) {
        return R.ok("保存成功",resumeService.addResume(addResumeDto,StpUtil.getLoginIdAsLong()));
    }

    @ApiOperation("根据id查询队伍信息")
    @SaCheckLogin//
    @PostMapping("findResumeByUserId")
    public RES findResumeByUserId(@ApiParam(name = "userId", value = "人员的id", required = true)
                            @RequestBody Map<String,Long> object)  {
        Long userId=object.get("userId");
        return R.ok(resumeService.getResume(userId));
    }

}
